//
//  NSString+DeviceId.m
//  StoneAPI
//
//  Created by 陈小东 on 15/3/14.
//  Copyright (c) 2015年 _____stone_chenxiaodong_____. All rights reserved.
//


#import <Foundation/Foundation.h>

#import "NSString+DeviceId.h"
#import <NSString+Nomal.h>
#import "SSKeychain.h"
#import "UtilsMacro.h"
#define UUID_Device @"UUID_Device"

@implementation NSString (DeviceId)
+ (NSString *)staticUUID
{
    if ([SSKeychain passwordForService:[self keyChainServer] account:UUID_Device])
    {
        return [SSKeychain passwordForService:[self keyChainServer] account:UUID_Device];
    }
    else
    {
        NSString * dynamicUUID = [[self UUID] MD5_16];
        [SSKeychain setPassword:dynamicUUID forService:[self keyChainServer] account:UUID_Device];
        return dynamicUUID;
    }
}

+ (BOOL)hasStaticUUID
{
    return [SSKeychain passwordForService:[self keyChainServer] account:UUID_Device];
}

+ (NSString *)keyChainServer
{
    return [NSString stringWithFormat:@"CXD.%@",kAppName];
}

@end
